<?php

namespace app\common\exception;

use think\Exception;
use Throwable;


/**
 * api接口异常
 * Class ApiException
 * @package app\common\exception
 * @author ^2_3^王尔贝
 */
class ApiException extends Exception
{
    public $code;
    public $msg;
    public $data;

    /**
     * ApiException constructor.
     * @param array $apiErrConst
     * @param array $data
     * @param Throwable|null $previous
     */
    public function __construct(array $apiErrConst, $data = [], Throwable $previous = null)
    {
        $code = $apiErrConst[0];
        $msg = $apiErrConst[1];

        $this->code = $code;
        $this->msg = $msg;
        $this->data = $data;

        parent::__construct($msg, $code, $previous);
    }
}